package com.anivia.common.core.model.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.io.Serializable;

/**
 * 分页查询公共参数
 *
 * @author wangj
 */
@Data
@Schema
public class BasePageDTO implements Serializable {
    @NotNull(message = "页码不能为空")
    @Min(value = 1, message = "页码最小为1")
    @Schema(description = "页码，从1开始")
    private Integer page = 1;

    @NotNull(message = "每页数量不能为空")
    @Max(value = 100, message = "每页数量最大为{value}")
    @Min(value = 1, message = "每页数量最小为{value}")
    @Schema(description = "每页数量[1,100]")
    private Integer size = 10;

    public Integer getPage() {
        return page == null ? 0 : page;
    }

    public Integer getSize() {
        return size == null ? 10 : size;
    }
}
